package com.blb.mapper;

import com.blb.entity.Ware;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author HuaHao
 * @since 2019-11-15
 */
public interface WareMapper extends BaseMapper<Ware> {
    /* 查询所有仓库 */
    @Select("select * from t_ware where company_id = #{companyId}")
    List<Ware> findAllWare2(String companyId);

    /* 根据id查询所有仓库 */
    @Select("select * from t_ware where company_id = #{companyId}")
    List<Ware> findAllWare(String companyId);

    /* 根据仓库id找出货区数目（添加货区用）*/
    @Select("select cargo_num from t_ware where id = #{Id}")
    String findCargoNumById(String id);

    /* 新增仓库 */
    @Insert("INSERT INTO t_ware(id,ware_no ,ware_name , person , telephone , cargo_num , details , dete_time, status,address ,place , company_id) VALUES (#{id},#{wareNo},#{wareName},#{person},#{telephone},#{cargoNum},#{details},#{deteTime},#{status},#{address},#{place},#{companyId})")
    void AddWare(Ware ware);

    /* 修改仓库 */
    @Update("UPDATE t_ware SET ware_no=#{wareNo},ware_name=#{wareName},person=#{person},telephone=#{telephone},cargo_num=#{cargoNum},details=#{details},address=#{address} where id= #{id}")
    void UpdateWare(Ware ware);

    /* 修改仓库（用作货区添加） */
    @Update("UPDATE t_ware SET cargo_num= #{cargoNum} WHERE id= #{id}")
    void UpdataCargoNum(Ware ware);

   /* 修改启用状态 */
    @Update("update t_ware set status = '0' where id= #{id}")
    void UpdateWareStatus(Ware ware);

    /* 修改停用用状态 */
    @Update("update t_ware set status = '1' where id= #{id}")
    void UpdateWareStatus1(Ware ware);

}
